var t = getApp();

Component({
    properties: {
        width: {
            value: "100%",
            type: String
        },
        height: {
            value: "100%",
            type: String
        },
        videoUrl: {
            value: "",
            type: String
        },
        limit: {
            value: 0,
            type: Number
        }
    },
    data: {},
    methods: {
        onReadVideo: function() {
            var t = this;
            wx.chooseVideo({
                sourceType: [ "album", "camera" ],
                maxDuration: 60,
                camera: "back",
                success: function(a) {
                    t.getDuration(a.duration, a.tempFilePath);
                }
            });
        },
        getDuration: function(a, i) {
            var e = a;
            return this.data.duration = e, console.log("视频时长：", this.data.duration, this.data.limit + 1, this.data.limit && this.data.duration > this.data.limit + 1), 
            this.data.duration < 1 ? (this.setData({
                videoUrl: null
            }), t.tips("视频时长太短了！")) : 0 != this.data.limit && this.data.duration > parseInt(this.data.limit) + 1 ? (this.setData({
                videoUrl: null
            }), t.tips("视频时长不能超过".concat(this.data.limit, "秒"))) : (this.setData({
                videoUrl: i
            }), void this.setSrcAndCaptureImage(i));
        },
        setSrcAndCaptureImage: function(t) {
            this.triggerEvent("beforeUp", t), this.uploadAudioM(t);
        },
        uploadAudioM: function(a) {
            var i = this, e = t.getNetAddresss("upload.uploadPic");
            e += "&upload_type=video", wx.uploadFile({
                url: e,
                filePath: a,
                name: "file",
                formData: {},
                success: function(t) {
                    var a = JSON.parse(t.data);
                    1 != a.result && i.setData({
                        videoUrl: null
                    }), i.triggerEvent("successUp", {
                        res: a
                    });
                }
            });
        }
    }
});